<script>
export default {
  name: 'DeviceWarningRecordDetail',
  props: {
    // 请求参数
    requestParams: {
      type: Object,
      default: () => ({})
    },
    // 弹窗数据
    popData: {
      type: Object,
      default: () => ({})
    },
    // 弹窗配置
    popConfig: {
      type: Object,
      default: () => ({})
    },
    // 弹窗取消
    close: {
      type: Boolean,
      default: false
    },
    // 弹窗确认
    confirm: {
      type: Boolean,
      default: false
    }
  },
  watch: {
    popData: {
      async handler(data) {
        const formData = data
        formData.warningThresholds = JSON.parse(formData.deviceDetails)
        if (data.id) {
          const detailRes = await this.$api.deviceWarningRecord.detail(data.id)
          formData.warningPushUsers = detailRes.data.warningPushUsers
        }
        this.formData = formData
      },
      deep: true,
      immediate: true
    },
    confirm() {
      this.$emit('onFinish', 'OperateDeviceWarningRecordDetail')
    }
  },
  data() {
    return {
      formData: {}
    }
  }
}
</script>

<template>
  <div class="detail-box">
    <el-row>
      <el-col :span="24">预警名称: {{ formData.warningName }}</el-col>
    </el-row>
    <el-row>
      <el-col :span="24">所属项目: {{ formData.projectName }}</el-col>
    </el-row>
    <el-row>
      <el-col :span="24">所属场景: {{ formData.sceneInfoName }}</el-col>
    </el-row>
<!--    <el-row>
      <el-col :span="24">预警信息: {{ formData.warningMsg }}</el-col>
    </el-row>-->
    <el-row>
      <el-col :span="24">预警时间: {{ formData.warningDate }}</el-col>
    </el-row>
    <el-row>
      <h2>设备预警详情</h2>
      <el-table :data="formData.warningThresholds">
        <el-table-column prop="deviceName" label="设备名称"></el-table-column>
        <el-table-column prop="modelName" label="设备参数"></el-table-column>
        <el-table-column prop="thresholdValue" label="预警值"></el-table-column>
      </el-table>
    </el-row>
    <el-row>
      <h2>信息状态详情</h2>
      <el-table :data="formData.warningPushUsers">
        <el-table-column prop="userName" label="用户"></el-table-column>
        <el-table-column prop="statusName" label="状态"></el-table-column>
        <el-table-column prop="readDate" label="查看时间"></el-table-column>
      </el-table>
    </el-row>
  </div>
</template>

<style scoped lang="scss">
.detail-box {
  .el-row {
    line-height: 28px;
  }
}
</style>
